package org.codingbug.duck;

import org.codingbug.duck.fla.FlyBehavior;
import org.codingbug.duck.quack.QuackBehavior;

/**
 * 
 * @ClassName: Duck 
 * @Description: TODO(鸭的超类) 
 * @author sam.zhang
 * @date 2012-10-3 上午1:25:23 
 *
 */
public abstract class Duck {
	protected FlyBehavior flyBehavior;
	protected QuackBehavior quackBehavior;
	
	public Duck(){
		
	}
	
	public abstract void display();
	
	/**
	 * 
	 * @Title: performFly 
	 * @Description: TODO(委托飞行的类) 
	 * @param     
	 * @return void    
	 * @throws
	 */
	public void performFly(){
		flyBehavior.fly();
	}
	
	/**
	 * 
	 * @Title: performQuack 
	 * @Description: TODO(委托叫声的类) 
	 * @param     
	 * @return void    
	 * @throws
	 */
	public void performQuack(){
		quackBehavior.quack();
	}
	
	public void swim() {
		System.out.println("All ducks float, even decoys!");
	}

	/**   
	 * @param flyBehavior the flyBehavior to set   
	 */
	public void setFlyBehavior(FlyBehavior flyBehavior) {
		this.flyBehavior = flyBehavior;
	}

	/**   
	 * @param quackBehavior the quackBehavior to set   
	 */
	public void setQuackBehavior(QuackBehavior quackBehavior) {
		this.quackBehavior = quackBehavior;
	}
}
